<?php
require_once('../../carbox.php');
if(!carbox_check_session( ))
	header('Location: http://'.$_SERVER['HTTP_HOST'].'/carbox/login.php');
carbox_query(
	"INSERT INTO DocumentAction (document_id, user_id, action_id, date) VALUES (:did, :uid, 1, NOW( ))",
	array(':uid' => $_SESSION['uid'], ':did' => $_GET["id"]) 
);

?>
<!DOCTYPE html>
<html lang="pt">
	<head>
		<meta charset="utf8" />
		<title>Carbox</title>
		<meta name="viewport" content="width=device-width, initial-scale=1.0" />
		<meta name="description" content="Sistema de visualização de documentos digitalizados" />
		<meta name="author" content="Thiago Medeiros de Menezes" />
		<link href="js/bootstrap/css/bootstrap.min.css" rel="stylesheet" type="text/css" />
		<link href="https://fonts.googleapis.com/css?family=Days+One" rel="stylesheet" type="text/css">
		<link href="css/carbox/carbox.css" rel="stylesheet" type='text/css' />
		<link rel="shortcut icon" href="imgs/logo.png">
		<link rel="apple-touch-icon-precomposed" sizes="144x144" href="imgs/logo.png">
		<link rel="apple-touch-icon-precomposed" sizes="114x114" href="imgs/logo.png">
		<link rel="apple-touch-icon-precomposed" sizes="72x72" href="imgs/logo.png">
		<link rel="apple-touch-icon-precomposed" href="imgs/logo.png">
		<style type="text/css" title="currentStyle">
			@import "js/datatables/media/css/demo_page.css";
			@import "js/datatables/media/css/demo_table_jui.css";
		</style>
	</head>
	<body>
		<div id="content" style="margin-left: 1%; width: 98%">
			<?php
			$mode = (strlen($_GET["id"]) == 10)? "PROC_PAGE" : "ONLY_DOC";
			for($i = 0; $i < $_GET["pages"]; ++$i)
				echo '<img style="width: 100%;" src="http://'.$_SERVER['HTTP_HOST'].'/carbox/php/docs/view/view.php?id='.$_GET["id"].'&mode='.$mode.'&page='.($i+1).'.jpg" />';
			?>
		</div>
		<script type="text/javascript" src="js/jquery/jquery-latest.min.js"></script>
		<script type="text/javascript" src="js/jquery-ui/jquery-ui-1.10.1.custom.min.js"></script>
		<script type="text/javascript" src="https://www.google.com/jsapi"></script>
		<script type="text/javascript" src="js/bootstrap/js/bootstrap.min.js"></script>
		<script type="text/javascript" src="js/datatables/media/js/jquery.dataTables.js"></script>
		<script type="text/javascript" src="js/carbox/carbox.js"></script>
		<script type="text/javascript"> window.print( ); </script>
	</body>
</html>
